package com.injurydetection.www.util.datautil;

/**
 * Created by sunguiyong on 2020/9/1
 */
public class MakePackage {
    /**
     * 体温
     *
     * @return
     */
    public static byte[] makeBytes() {
        byte[] ret = new byte[6];
        byte[] ret2 = new byte[8];
        int crc = 0;
        ret[0] = 0x01;
        ret[1] = 0x03;
        ret[2] = 0x00;
        ret[3] = 0x00;
        ret[4] = 0x00;
        ret[5] = 0x08;
        crc = CRC16E.CRC16_MODBUS(ret) & 0x00ffff;

        for (int i = 0; i < ret.length; i++) {
            ret2[i] = ret[i];
        }
        ret2[6] = (byte) (crc % 256);
        ret2[7] = (byte) (crc / 256);
        return ret2;
    }

    /**
     * 血压
     * 0x55 0xAA 0x04 0x02 0x01 0xF8   血压
     */
    public static byte[] makeBytes1() {
        byte[] ret = new byte[6];
        ret[0] = 0x55;
        ret[1] = (byte) 0xAA;
        ret[2] = 0x04;
        ret[3] = 0x02;
        ret[4] = 0x01;
        ret[5] = (byte) 0xF8;
        return ret;
    }

    /**
     * 血氧
     * 0x55 0xAA 0x04 0x03 0x01 0xF7   血氧
     */
    public static byte[] makeBytes2() {
        byte[] ret = new byte[6];
        ret[0] = 0x55;
        ret[1] = (byte) 0xAA;
        ret[2] = 0x04;
        ret[3] = 0x03;
        ret[4] = 0x01;
        ret[5] = (byte) 0xF7;
        return ret;
    }

    /**
     * 心电
     * 0x55 0xAA 0x04 0x03 0x01 0xF7
     */
    public static byte[] makeBytes3() {
        byte[] ret = new byte[6];
        ret[0] = 0x55;
        ret[1] = (byte) 0xAA;
        ret[2] = 0x04;
        ret[3] = 0x01;
        ret[4] = 0x01;
        ret[5] = (byte) 0xF9;
        return ret;
    }

    /**
     * 心电波形
     * 0x55 0xAA 0x04 0xFB 0x01 0xFF
     */
    public static byte[] makeBytes4() {
        byte[] ret = new byte[6];
        ret[0] = 0x55;
        ret[1] = (byte) 0xAA;
        ret[2] = 0x04;
        ret[3] = (byte) 0xFB;
        ret[4] = 0x01;
        ret[5] = (byte) 0xFF;
        return ret;
    }


    public static byte[] cmd_find = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x01, 0x22};
    public static byte[] cmd_selt = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x02, 0x21};
    public static byte[] cmd_read = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x30, 0x01, 0x32};

}
